<?php
namespace app\admin\exports;

use app\admin\support\excel\ExcelContract;
use app\admin\support\excel\Export;

abstract class BaseExport implements ExcelContract
{
    protected string $extension = 'xlsx';

    public function getExtension(): string
    {
        return $this->extension;
    }

    public function setExtension(string $ext): static
    {
        $this->extension = $ext;

        return $this;
    }

    public function download()
    {
        // TODO: Implement download() method.
        $excel = new Export();

        return $excel->setExtension($this->getExtension())->save($this);
    }

    public function asCsv(): static
    {
        return $this->setExtension('csv');
    }
}
